#!/bin/bash

f=results/merged.list

while read -r line
do
	grep -q "^$line$" results/build_run-ok.list && continue
	o="$(abf show -p import/"$line")"
	repo=""
	if echo "$o" | grep -q rosa2021.15/contrib; then
		repo=contrib
	elif echo "$o" | grep -q rosa2021.15/main; then
		repo=main
	fi
	if [ -z "$repo" ]; then
		echo "$line" >> results/build_get-repo-errors.list
		continue
	fi
	case "$repo" in
		main) add="-l 4664495 -l 4664496 -l 4664497" ;;
		contrib) add="-l 4664495 -l 4664496 -l 4664497 -l 4664498 -l 4664499 -l 4664500" ;;
	esac
	if abf build -b rosa2021.15 $add -p import/"$line" --no-extra-tests --arch aarch64 --arch x86_64 --arch i686 ; then
		echo "$line" >> results/build_run-ok.list
	else
		echo "$line" >> results/build_run-errors.list
	fi
done < "$f"
#done < <(echo baka-mplayer)
